package com.imooc.mapping.course1.copier;

import com.imooc.mapping.course1.Metadata;
import com.imooc.mapping.course1.TDataCenterMetadata;
import com.imooc.module.collect.enums.SourceTypeEnum;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * @Author Tim
 * @Description:
 * @Version 1.0
 */
@Mapper
public interface MetadataCopier {
    MetadataCopier INSTANCE = Mappers.getMapper(MetadataCopier.class);

    @Mapping(source="sourceType",target = "sourceType", qualifiedByName = "toSourceType")
    Metadata metadataCopier(TDataCenterMetadata metadata);

    @Named("toSourceType")
    default SourceTypeEnum toSourceType(Integer st){
        return SourceTypeEnum.parse(st);
    }
}
